package dao

import (
	"context"
	"go-mall/model"
	"gorm.io/gorm"
)

type CategoriesDao struct {
	*gorm.DB
}

func NewCategoriesDao(ctx context.Context) *CategoriesDao {
	return &CategoriesDao{NewDBCliet(ctx)}
}

// 获取全部分类
func (dao *CategoriesDao) ListCategories() (categories []*model.Categories, err error) {
	err = dao.DB.Model(&model.Categories{}).Find(&categories).Error
	//err = dao.DB.Debug().Model(&model.Categories{}).Find(&categories).Error
	return categories, err

}
